package cn.iocoder.yudao.module.infra.api.ocr;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.infra.api.ocr.dto.OcrRecognizeRespDTO;
import cn.iocoder.yudao.module.infra.service.ocr.OcrService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * OCR API 实现类
 *
 * @author 芋道源码
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class OcrApiImpl implements OcrApi {

    @Resource
    private OcrService ocrService;

    @Override
    public CommonResult<OcrRecognizeRespDTO> recognizeIdCard(Long configId, Long fileId) {
        return success(ocrService.recognizeIdCardForApi(configId, fileId));
    }

    @Override
    public CommonResult<OcrRecognizeRespDTO> recognizeDrivingLicense(Long configId, Long fileId) {
        return success(ocrService.recognizeDrivingLicenseForApi(configId, fileId));
    }

    @Override
    public CommonResult<OcrRecognizeRespDTO> recognizeText(Long configId, Long fileId) {
        return success(ocrService.recognizeTextForApi(configId, fileId));
    }

}